﻿package component.fileupload.action;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import component.fileupload.exception.FileUploadException;

/**
 * 文件下载的接口
 */
public interface IFileDownloadAction {
	
	/**
	 * 设置要保存在服务器上的相对路径
	 * @param savePath
	 */
	public void setSaveFilePath(String saveFilePath);
	
	/**
	 * 下载文件
	 * @param servletContext
	 * @param request
	 * @param response
	 * @param filePath：文件路径
	 * @param fileName：文件名称
	 * @return
	 * @throws FileUploadException
	 */
	public String doDownload(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, String filePath, String fileName) throws FileUploadException ;

	/**
	 * 从服务器上下载文件
	 * @param httpFile：服务器上的文件路径, 如 http://localhost:8088/fileupload/data/test/test.txt
	 * @param localFilePath：本地的文件路径, 如 d:/dowloads
	 * @param saveFileName：保存的文件名
	 * @return
	 */
	public String doDownload(String httpFile, String localFilePath, String saveFileName) throws FileUploadException ;
	
	/**
	 * 多线程断点续传文件：文件名不要有空格，不能保存为已有文件中
	 * @param httpFile
	 * @param localFilePath
	 * @param saveFileName
	 * @param breakpoint
	 * @return
	 * @throws FileUploadException
	 */
	public String doReDownload(String httpFile, String localFilePath, String saveFileName, int breakpoint) throws FileUploadException ;
}
